<template>
	<view>
		<view class="goodsList">
			<goodsList :goods="goods"></goodsList>
		</view>
	</view>
</template>

<script>
	import goodsList from '../components/goods-list/goods-list.vue'
	export default {
		data(){
			return{			
				goods:[]
			}
		},
		onPullDownRefresh() {
			this.goods=[]
			this.getGoodsList(()=>{
				uni.stopPullDownRefresh()
				console.log("callback")
			})
		},
		onLoad() {
			this.getGoodsList()
		},
		components:{
			goodsList
		},
		methods: {
			async getGoodsList(callback){
				const res = await this.$myRequest({
					url:'/api/getGoods.json'
				})
				this.goods = res.data.message
				callback && callback()//下拉刷新完毕，关闭下拉刷新
			}
		}
	}
</script>

<style lang="scss">
	.goodsList{
		background:#eee;
	}
</style>
